/**
 * reply-actor
 * @authors 杨兴洲（of2502）
 * @date    2017/5/25 0025 20:23
 * @version 1.0
 * @last-modify  杨兴洲（of2502）
 */


import {Map, List} from 'immutable'
import {Action, Actor} from 'iflux2';
import * as types from '../constants/actionTypes'
export default class ReplyActor extends Actor {
    defaultState() {
        return {
            kw_list: List(),
            kw_page: 1,
            kw_total: 0,
            kw_pageSize: 2,
            // 关注
            followReply: {}
        }
    }

    /**
     * 获取关键词回复列表
     * @param {*} state
     * @param {*} data
     */
    @Action(types.FETCH_FOLLOW_REPLY)
    fetchFollowReply(state, data) {
        return state.set('followReply', data);
    }

    @Action(types.DELETE_FOLLOW_REPLY)
    deleteFollowReply(state) {
        return state.set('followReply', {});
    }

    /**
     * 获取关键词回复列表
     * @param {*} state
     * @param {*} list
     * @param {*} total
     * @param {*} pageSize
     */
    @Action(types.FETCH_KEYWORD_REPLY_LIST)
    fetchKeywordReplyList(state, {list, total, pageNo, pageSize}) {
        return state.set('kw_list', list)
            .set('kw_total', total)
            .set('kw_page', pageNo)
            .set('kw_pageSize', pageSize)
    }

    /**
     * 新增规则后,初始化列表
     * @param state
     */
    @Action(types.INIT_PAGINATION)
    initPagination(state) {
        return state.set('kw_page', 1);
    }
}